package cn.cvs.servlet;

import cn.cvs.pojo.Fruit;
import cn.cvs.service.FruitService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/FruitServlet")
public class FruitServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        super.doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        FruitService fruit = new FruitService();
        int fruitId = Integer.parseInt(request.getParameter("fruitId"));
        Fruit f = fruit.FruitList(fruitId);
        request.setAttribute("f",f);
        request.getRequestDispatcher("fruitList.jsp").forward(request,response);
    }
}
